﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;

internal static class MetroVisualStudioSolutionCreator
{
    [CompilerGenerated]
    private static Dictionary<string, int> <>f__switch$map9;

    private static void CreateDirectoryIfMissing(string dir)
    {
        if (!Directory.Exists(dir))
        {
            Directory.CreateDirectory(dir);
        }
    }

    public static void CreateSolutionFileFrom(string name, string srcDirectory, string targetDirectory, string[] _dontOverwriteFiles, bool sourceBuild)
    {
        List<string> list = new List<string>(_dontOverwriteFiles);
        string pfxFile = null;
        string str2 = null;
        string manifestFile = null;
        List<string> list2 = new List<string>();
        string[] collection = new string[] { "pch.cpp", "pch.h", "App.xaml", "App.xaml.cpp", "App.xaml.h", "MainPage.xaml", "MainPage.xaml.cpp", "MainPage.xaml.h", @"Common\StandardStyles.xaml", @"Assets\SquareTile.png", @"Assets\SmallTile.png", @"Assets\StoreLogo.png", @"Assets\SplashScreen.png" };
        List<string> list3 = new List<string>(collection);
        try
        {
            string[] strArray = Directory.GetFiles(srcDirectory, "*.*", SearchOption.AllDirectories);
            for (int i = 0; i < strArray.Length; i++)
            {
                string file = strArray[i].Substring(srcDirectory.Length + 1);
                if (file.IndexOf(@"Players\") != 0)
                {
                    if (file.IndexOf(".pfx") != -1)
                    {
                        pfxFile = file;
                    }
                    else if (file.IsManifestFileName())
                    {
                        str2 = file;
                        file = "Package.appxmanifest";
                        manifestFile = file;
                    }
                    if (!list3.Contains(file) && (file.IndexOf(".metadata") == -1))
                    {
                        list2.Add(file);
                    }
                }
            }
        }
        catch (Exception exception)
        {
            throw new Exception(string.Format("Failed to get files from {0}, {1}", srcDirectory, exception.Message));
        }
        if (pfxFile == null)
        {
            throw new Exception(string.Format("Failed to find *.pfx file in {0}", srcDirectory));
        }
        if (manifestFile == null)
        {
            throw new Exception(string.Format("Failed to find *.appxmanifest file in {0}", srcDirectory));
        }
        List<string> list4 = new List<string>();
        foreach (string str5 in list2)
        {
            for (int j = 0; (j = str5.IndexOf(@"\", j)) != -1; j++)
            {
                string item = str5.Substring(0, j);
                if (!list4.Contains(item))
                {
                    list4.Add(item);
                }
            }
        }
        string[] directories = list4.ToArray();
        CreateDirectoryIfMissing(targetDirectory);
        string str7 = name + ".sln";
        WriteSolutionFile(Path.Combine(srcDirectory, str7), name, sourceBuild);
        string str8 = name + ".vcxproj.filters";
        string str9 = name + ".vcxproj";
        WriteVCXProjFilters(Path.Combine(srcDirectory, str8), directories, list2.ToArray());
        WriteVCXProj(Path.Combine(srcDirectory, str9), manifestFile, pfxFile, list2.ToArray(), sourceBuild);
        list.Add(str8);
        list.Add(str9);
        list3.Add(str8);
        list3.Add(str9);
        if (!File.Exists(Path.Combine(targetDirectory, str7)))
        {
            File.Copy(Path.Combine(srcDirectory, str7), Path.Combine(targetDirectory, str7), true);
        }
        string dir = Path.Combine(targetDirectory, name);
        CreateDirectoryIfMissing(dir);
        foreach (string str11 in directories)
        {
            CreateDirectoryIfMissing(Path.Combine(dir, str11));
        }
        CreateDirectoryIfMissing(Path.Combine(dir, "Common"));
        CreateDirectoryIfMissing(Path.Combine(dir, "Assets"));
        foreach (string str12 in list3)
        {
            string path = Path.Combine(srcDirectory, str12);
            string str14 = Path.Combine(dir, str12);
            if (File.Exists(path))
            {
                if (!File.Exists(str14) || !list.Contains(str12))
                {
                    File.Copy(path, str14, true);
                }
            }
            else if (str12.IndexOf(".pdb") == -1)
            {
                throw new Exception(string.Format("Failed to find " + path, new object[0]));
            }
        }
        foreach (string str15 in list2)
        {
            string str16 = str15;
            if (str16.IsManifestFileName())
            {
                str16 = str2;
            }
            string sourceFileName = Path.Combine(srcDirectory, str16);
            string str18 = Path.Combine(dir, str15);
            if (!File.Exists(str18) || !list.Contains(str16))
            {
                File.Copy(sourceFileName, str18, true);
            }
        }
    }

    private static string GetSolutionTemplate()
    {
        string[] textArray1 = new string[] { 
            "Microsoft Visual Studio Solution File, Format Version 12.00", "# Visual Studio 11", "Project(\"{{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}}\") = \"{0}\", \"{0}\\{0}.vcxproj\", \"{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}\"", "EndProject", "Global", "    GlobalSection(SolutionConfigurationPlatforms) = preSolution", "        Debug|ARM = Debug|ARM", "        Debug|Win32 = Debug|Win32", "        Debug|x64 = Debug|x64", "        Release|ARM = Release|ARM", "        Release|Win32 = Release|Win32", "        Release|x64 = Release|x64", "    EndGlobalSection", "    GlobalSection(ProjectConfigurationPlatforms) = postSolution", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|ARM.ActiveCfg = Debug|ARM", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|ARM.Build.0 = Debug|ARM", 
            "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|ARM.Deploy.0 = Debug|ARM", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|Win32.ActiveCfg = Debug|Win32", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|Win32.Build.0 = Debug|Win32", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|Win32.Deploy.0 = Debug|Win32", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|x64.ActiveCfg = Debug|x64", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|x64.Build.0 = Debug|x64", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|x64.Deploy.0 = Debug|x64", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|ARM.ActiveCfg = Release|ARM", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|ARM.Build.0 = Release|ARM", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|ARM.Deploy.0 = Release|ARM", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|Win32.ActiveCfg = Release|Win32", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|Win32.Build.0 = Release|Win32", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|Win32.Deploy.0 = Release|Win32", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|x64.ActiveCfg = Release|x64", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|x64.Build.0 = Release|x64", "        {{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|x64.Deploy.0 = Release|x64", 
            "    EndGlobalSection", "    GlobalSection(SolutionProperties) = preSolution", "        HideSolutionNode = FALSE", "    EndGlobalSection", "EndGlobal"
         };
        return string.Join("\r\n", textArray1);
    }

    private static string GetSourceBuildSolutionTemplate()
    {
        string[] textArray1 = new string[] { 
            "Microsoft Visual Studio Solution File, Format Version 12.00", "# Visual Studio 2012", "Project(\"{{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}}\") = \"{0}\", \"{0}\\{0}.vcxproj\", \"{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}\"", "\tProjectSection(ProjectDependencies) = postProject", "\t\t{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}} = {{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}", "\tEndProjectSection", "EndProject", "Project(\"{{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}}\") = \"MetroSupportLib\", \"..\\..\\..\\Projects\\JamGeneratedMetro\\_workspace.vs2010_\\MetroSupportLib.vcxproj\", \"{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}\"", "EndProject", "Global", "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution", "\t\tDebug|ARM = Debug|ARM", "\t\tDebug|Win32 = Debug|Win32", "\t\tDebug|x64 = Debug|x64", "\t\tRelease|ARM = Release|ARM", "\t\tRelease|Win32 = Release|Win32", 
            "\t\tRelease|x64 = Release|x64", "\tEndGlobalSection", "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|ARM.ActiveCfg = Debug|ARM", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|ARM.Build.0 = Debug|ARM", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|ARM.Deploy.0 = Debug|ARM", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|Win32.ActiveCfg = Debug|Win32", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|Win32.Build.0 = Debug|Win32", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|Win32.Deploy.0 = Debug|Win32", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|x64.ActiveCfg = Debug|x64", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|x64.Build.0 = Debug|x64", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Debug|x64.Deploy.0 = Debug|x64", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|ARM.ActiveCfg = Release|ARM", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|ARM.Build.0 = Release|ARM", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|ARM.Deploy.0 = Release|ARM", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|Win32.ActiveCfg = Release|Win32", 
            "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|Win32.Build.0 = Release|Win32", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|Win32.Deploy.0 = Release|Win32", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|x64.ActiveCfg = Release|x64", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|x64.Build.0 = Release|x64", "\t\t{{D6208586-8638-4BE1-BD2C-9A55EEC34747}}.Release|x64.Deploy.0 = Release|x64", "\t\t{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}.Debug|ARM.ActiveCfg = Debug|ARM", "\t\t{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}.Debug|ARM.Build.0 = Debug|ARM", "\t\t{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}.Debug|Win32.ActiveCfg = Debug|Win32", "\t\t{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}.Debug|Win32.Build.0 = Debug|Win32", "\t\t{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}.Debug|x64.ActiveCfg = Debug|Win32", "\t\t{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}.Release|ARM.ActiveCfg = Release|ARM", "\t\t{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}.Release|ARM.Build.0 = Release|ARM", "\t\t{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}.Release|Win32.ActiveCfg = Release|Win32", "\t\t{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}.Release|Win32.Build.0 = Release|Win32", "\t\t{{59D28A4A-ABA9-4BDF-A2B6-AB532C6DADFE}}.Release|x64.ActiveCfg = Release|Win32", "\tEndGlobalSection", 
            "\tGlobalSection(SolutionProperties) = preSolution", "\t\tHideSolutionNode = FALSE", "\tEndGlobalSection", "EndGlobal"
         };
        return string.Join("\r\n", textArray1);
    }

    public static string GetTagForFile(string file)
    {
        string str = "App.xaml";
        if (file.IndexOf(str) == (file.Length - str.Length))
        {
            return "ApplicationDefinition";
        }
        if (file.IsManifestFileName())
        {
            return "AppxManifest";
        }
        if (file.IndexOf(".png") == (file.Length - 4))
        {
            return "Image";
        }
        if (file.IndexOf(".cpp") == (file.Length - 4))
        {
            return "CLCompile";
        }
        if (file.IndexOf(".h") == (file.Length - 2))
        {
            return "CLInclude";
        }
        if (file.IndexOf(".xaml") == (file.Length - 5))
        {
            return "Page";
        }
        return "None";
    }

    private static string GetVCXProjFiltersTemplate()
    {
        string[] textArray1 = new string[] { 
            "<?xml version=\"1.0\" encoding=\"utf-8\"?>", "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">", " <ItemGroup>", "    <Filter Include=\"Common\">", "      <UniqueIdentifier>e2f6d0cd-0678-4dd6-a4f5-8ba54587bb73</UniqueIdentifier>", "    </Filter>", "    <Filter Include=\"Assets\">", "      <UniqueIdentifier>01b9bdf6-d7d6-419d-8bdb-b0eec59ff5e8</UniqueIdentifier>", "    </Filter>", "    <Page Include=\"Common\\StandardStyles.xaml\">", "      <Filter>Common</Filter>", "    </Page>", "    <Image Include=\"Assets\\SquareTile.png\">", "      <Filter>Assets</Filter>", "    </Image>", "    <Image Include=\"Assets\\SmallTile.png\">", 
            "      <Filter>Assets</Filter>", "    </Image>", "    <Image Include=\"Assets\\StoreLogo.png\">", "      <Filter>Assets</Filter>", "    </Image>", "    <Image Include=\"Assets\\SplashScreen.png\">", "      <Filter>Assets</Filter>", "    </Image>", "  </ItemGroup>", "  <ItemGroup>", "    <ApplicationDefinition Include=\"App.xaml\" />", "  </ItemGroup>", "  <ItemGroup>", "    <ClCompile Include=\"App.xaml.cpp\" />", "    <ClCompile Include=\"MainPage.xaml.cpp\" />", "    <ClCompile Include=\"pch.cpp\" />", 
            "  </ItemGroup>", "  <ItemGroup>", "    <ClInclude Include=\"pch.h\" />", "    <ClInclude Include=\"App.xaml.h\" />", "    <ClInclude Include=\"MainPage.xaml.h\" />", "  </ItemGroup>", "  <ItemGroup>", "    <AppxManifest Include=\"Package.appxmanifest\" />", "  </ItemGroup>", "  <ItemGroup>", "    <Page Include=\"MainPage.xaml\" />", "  </ItemGroup>", "  <ItemGroup>", "{0}", "  </ItemGroup>", "</Project>"
         };
        return string.Join("\r\n", textArray1);
    }

    private static string GetVCXProjTemplate()
    {
        string[] textArray1 = new string[] { 
            "<?xml version=\"1.0\" encoding=\"utf-8\"?>", "<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">", "  <ItemGroup Label=\"ProjectConfigurations\">", "    <ProjectConfiguration Include=\"Debug|Win32\">", "      <Configuration>Debug</Configuration>", "      <Platform>Win32</Platform>", "    </ProjectConfiguration>", "    <ProjectConfiguration Include=\"Release|Win32\">", "      <Configuration>Release</Configuration>", "      <Platform>Win32</Platform>", "    </ProjectConfiguration>", "    <ProjectConfiguration Include=\"Debug|x64\">", "      <Configuration>Debug</Configuration>", "      <Platform>x64</Platform>", "    </ProjectConfiguration>", "    <ProjectConfiguration Include=\"Release|x64\">", 
            "      <Configuration>Release</Configuration>", "      <Platform>x64</Platform>", "    </ProjectConfiguration>", "    <ProjectConfiguration Include=\"Debug|ARM\">", "      <Configuration>Debug</Configuration>", "      <Platform>ARM</Platform>", "    </ProjectConfiguration>", "    <ProjectConfiguration Include=\"Release|ARM\">", "      <Configuration>Release</Configuration>", "      <Platform>ARM</Platform>", "    </ProjectConfiguration>", "  </ItemGroup>", "  <PropertyGroup Label=\"Globals\">", "    <ProjectGuid>{{d6208586-8638-4be1-bd2c-9a55eec34747}}</ProjectGuid>", "    <RootNamespace>DeployProject2</RootNamespace>", "    <DefaultLanguage>en-US</DefaultLanguage>", 
            "    <VCTargetsPath Condition=\"'$(VCTargetsPath11)' != '' and '$(VSVersion)' == '' and '$(VisualStudioVersion)' == ''\">$(VCTargetsPath11)</VCTargetsPath>", "    <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>", "    <AppContainerApplication>true</AppContainerApplication>", "  </PropertyGroup>", "  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />", "  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">", "    <ConfigurationType>Application</ConfigurationType>", "    <UseDebugLibraries>true</UseDebugLibraries>", "    <PlatformToolset>v110</PlatformToolset>", "  </PropertyGroup>", "  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\" Label=\"Configuration\">", "    <ConfigurationType>Application</ConfigurationType>", "    <UseDebugLibraries>true</UseDebugLibraries>", "    <PlatformToolset>v110</PlatformToolset>", "  </PropertyGroup>", "  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">", 
            "    <ConfigurationType>Application</ConfigurationType>", "    <UseDebugLibraries>true</UseDebugLibraries>", "    <PlatformToolset>v110</PlatformToolset>", "  </PropertyGroup>", "  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">", "    <ConfigurationType>Application</ConfigurationType>", "    <UseDebugLibraries>false</UseDebugLibraries>", "    <WholeProgramOptimization>true</WholeProgramOptimization>", "    <PlatformToolset>v110</PlatformToolset>", "  </PropertyGroup>", "  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\" Label=\"Configuration\">", "    <ConfigurationType>Application</ConfigurationType>", "    <UseDebugLibraries>false</UseDebugLibraries>", "    <WholeProgramOptimization>true</WholeProgramOptimization>", "    <PlatformToolset>v110</PlatformToolset>", "  </PropertyGroup>", 
            "  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">", "    <ConfigurationType>Application</ConfigurationType>", "    <UseDebugLibraries>false</UseDebugLibraries>", "    <WholeProgramOptimization>true</WholeProgramOptimization>", "    <PlatformToolset>v110</PlatformToolset>", "  </PropertyGroup>", "  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />", "  <ImportGroup Label=\"ExtensionSettings\">", "  </ImportGroup>", "  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">", "    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />", "  </ImportGroup>", "  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">", "    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />", "  </ImportGroup>", "  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\">", 
            "    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />", "  </ImportGroup>", "  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\">", "    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />", "  </ImportGroup>", "  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">", "    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />", "  </ImportGroup>", "  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">", "    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />", "  </ImportGroup>", "  <PropertyGroup Label=\"UserMacros\" />", "  <PropertyGroup>", "    <PackageCertificateKeyFile>{0}</PackageCertificateKeyFile>", "    <AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>", "  </PropertyGroup>", 
            "  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\">", "   <ClCompile>", "       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>", "   </ClCompile>", "   </ItemDefinitionGroup>", "   <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\">", "     <ClCompile>", "       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>", "     </ClCompile>", "   </ItemDefinitionGroup>", "   <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">", "     <ClCompile>", "       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>", "     </ClCompile>", "   </ItemDefinitionGroup>", "   <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">", 
            "     <ClCompile>", "       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>", "     </ClCompile>", "   </ItemDefinitionGroup>", "   <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">", "     <ClCompile>", "       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>", "     </ClCompile>", "   </ItemDefinitionGroup>", "   <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">", "     <ClCompile>", "       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>", "     </ClCompile>", "   </ItemDefinitionGroup>", "   <ItemGroup>", "     <ClInclude Include=\"pch.h\" />", 
            "     <ClInclude Include=\"App.xaml.h\">", "       <DependentUpon>App.xaml</DependentUpon>", "     </ClInclude>", "     <ClInclude Include=\"MainPage.xaml.h\">", "       <DependentUpon>MainPage.xaml</DependentUpon>", "     </ClInclude>", "   </ItemGroup>", "   <ItemGroup>", "     <ApplicationDefinition Include=\"App.xaml\">", "       <SubType>Designer</SubType>", "     </ApplicationDefinition>", "     <Page Include=\"Common\\StandardStyles.xaml\">", "       <SubType>Designer</SubType>", "     </Page>", "     <Page Include=\"MainPage.xaml\">", "       <SubType>Designer</SubType>", 
            "     </Page>", "   </ItemGroup>", "   <ItemGroup>", "     <AppxManifest Include=\"Package.appxmanifest\">", "       <SubType>Designer</SubType>", "     </AppxManifest>", "     <None Include=\"{0}\" />", "   </ItemGroup>", "   <ItemGroup>", "     <Image Include=\"Assets\\SquareTile.png\" />", "     <Image Include=\"Assets\\SmallTile.png\" />", "     <Image Include=\"Assets\\StoreLogo.png\" />", "     <Image Include=\"Assets\\SplashScreen.png\" />", "   </ItemGroup>", "   <ItemGroup>", "     <ClCompile Include=\"App.xaml.cpp\">", 
            "       <DependentUpon>App.xaml</DependentUpon>", "     </ClCompile>", "     <ClCompile Include=\"MainPage.xaml.cpp\">", "       <DependentUpon>MainPage.xaml</DependentUpon>", "     </ClCompile>", "     <ClCompile Include=\"pch.cpp\">", "       <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">Create</PrecompiledHeader>", "       <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">Create</PrecompiledHeader>", "       <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\">Create</PrecompiledHeader>", "       <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\">Create</PrecompiledHeader>", "       <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Create</PrecompiledHeader>", "       <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Create</PrecompiledHeader>", "     </ClCompile>", "   </ItemGroup>", "   <ItemGroup>", "    <Reference Include=\"UnityPlayer\">", 
            @"      <HintPath>..\Players\$(TargetedSDKArchitecture)\lib\$(Configuration)\UnityPlayer.winmd</HintPath>", "      <IsWinMDFile>true</IsWinMDFile>", "    </Reference>", "    <Reference Include=\"WinRTBridge\">", @"      <HintPath>..\Players\$(TargetedSDKArchitecture)\lib\$(Configuration)\WinRTBridge.winmd</HintPath>", "      <IsWinMDFile>true</IsWinMDFile>", "    </Reference>", "   </ItemGroup>", "   <ItemGroup>", "    {1}", "   </ItemGroup>", "  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />", "  <ImportGroup Label=\"ExtensionTargets\">", "  </ImportGroup>", "</Project>"
         };
        return string.Join("\r\n", textArray1);
    }

    private static bool IsManifestFileName(this string file)
    {
        return ((file.IndexOf(".appxmanifest") != -1) || (file.IndexOf("AppxManifest.xml") != -1));
    }

    private static void WriteSolutionFile(string solutionFileName, string vcprojFileName, bool sourceBuild)
    {
        string contents = string.Format(!sourceBuild ? GetSolutionTemplate() : GetSourceBuildSolutionTemplate(), vcprojFileName);
        File.WriteAllText(solutionFileName, contents);
    }

    private static void WriteVCXProj(string fileName, string manifestFile, string pfxFile, string[] files, bool sourceBuild)
    {
        StringBuilder builder = new StringBuilder();
        foreach (string str in files)
        {
            if ((str.IndexOf(".pfx") != -1) || str.IsManifestFileName())
            {
                continue;
            }
            string tagForFile = GetTagForFile(str);
            builder.AppendLine(string.Format("{0}<{1} Include=\"{2}\" >", "\t", tagForFile, str));
            string key = tagForFile;
            if (key != null)
            {
                int num2;
                if (<>f__switch$map9 == null)
                {
                    Dictionary<string, int> dictionary = new Dictionary<string, int>(2);
                    dictionary.Add("Page", 0);
                    dictionary.Add("Image", 1);
                    <>f__switch$map9 = dictionary;
                }
                if (<>f__switch$map9.TryGetValue(key, out num2))
                {
                    if (num2 == 0)
                    {
                        builder.AppendLine(string.Format("{0}<SubType>Designer</SubType>", "\t\t"));
                        goto Label_00F5;
                    }
                    if (num2 == 1)
                    {
                        goto Label_00F5;
                    }
                }
            }
            builder.AppendLine(string.Format("{0}<DeploymentContent>true</DeploymentContent>", "\t\t"));
        Label_00F5:
            builder.AppendLine(string.Format("{0}</{1}>", "\t", tagForFile));
        }
        string vCXProjTemplate = GetVCXProjTemplate();
        if (sourceBuild)
        {
            vCXProjTemplate = vCXProjTemplate.Replace(@"<HintPath>..\Players\$(TargetedSDKArchitecture)\lib\$(Configuration)\UnityPlayer.winmd</HintPath>", @"<HintPath>..\..\Players\$(TargetedSDKArchitecture)\lib\$(Configuration)\UnityPlayer.winmd</HintPath>").Replace(@"<HintPath>..\Players\$(TargetedSDKArchitecture)\lib\$(Configuration)\WinRTBridge.winmd</HintPath>", @"<HintPath>..\..\Players\$(TargetedSDKArchitecture)\lib\$(Configuration)\WinRTBridge.winmd</HintPath>");
        }
        string contents = string.Format(vCXProjTemplate, pfxFile, builder);
        File.WriteAllText(fileName, contents);
    }

    private static void WriteVCXProjFilters(string fileName, string[] directories, string[] files)
    {
        StringBuilder builder = new StringBuilder();
        foreach (string str in directories)
        {
            builder.AppendLine(string.Format("{0}<Filter Include=\"{1}\" />", "\t", str));
        }
        foreach (string str2 in files)
        {
            string tagForFile = GetTagForFile(str2);
            builder.AppendLine(string.Format("{0}<{1} Include=\"{2}\" >", "\t", tagForFile, str2));
            int length = str2.LastIndexOf(@"\");
            if (length != -1)
            {
                string str4 = str2.Substring(0, length);
                builder.AppendLine(string.Format("{0}<Filter>{1}</Filter>", "\t\t", str4));
            }
            builder.AppendLine(string.Format("{0}</{1}>", "\t", tagForFile));
        }
        string contents = string.Format(GetVCXProjFiltersTemplate(), builder.ToString());
        File.WriteAllText(fileName, contents);
    }
}

